﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class NationalController
    {
        public int InsertNational(NationalInfo info)
        {
            return SQL.InsertNational(info.ContinentId, info.NationalName, info.PriceMadeVisa);
        }
        public void UpdateNational(NationalInfo info)
        {
            SQL.UpdateNational(info.NationalId, info.ContinentId, info.NationalName, info.PriceMadeVisa);
        }
        public void DeleteNational(NationalInfo info)
        {
            DeleteNational(info.NationalId);
        }
        public void DeleteNational(int nationalId)
        {
            SQL.DeleteNational(nationalId);
        }
        public NationalInfo GetNational(int nationalId)
        {
            return CBO.FillObject<NationalInfo>(SQL.GetNational(nationalId));
        }
        public List<NationalInfo> ListNational()
        {
            return CBO.FillCollection<NationalInfo>(SQL.ListNational());
        }
        public List<NationalInfo> ListNationalByContinent(int continentId)
        {
            return CBO.FillCollection<NationalInfo>(SQL.ListNationalByContinent(continentId));
        }
        public DataTable SelectNational()
        {
            return CBO.ConvertToDataTable(ListNational(), typeof(NationalInfo));
        }
        public Dictionary<object, object> ListNationalLookup()
        {
            var users = ListNational().OrderBy(p=>p.NationalName);
            var dicusers = new Dictionary<object, object>();
            foreach (var info in users)
                dicusers.Add(info.NationalId, info.NationalName);

            return dicusers;
        }
    }
}
